#include "controller_task.h"

#include "usart.h"
#include "cmsis_os.h"
#include "task.h"


#include "dwt.h"
#include "controller_data.h"


extern Controller_t tx_data; // 自定义控制器发送的数据
uint32_t pwm_data = 500;


static void controller_task(void *parameter)
{
    for(;;) {
        uint32_t wait_time = xTaskGetTickCount();
        uint8_t data[DATA_LENGTH] = {0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0x10};
        Data_Concatenation(data, DATA_LENGTH);
        HAL_UART_Transmit(&huart1, (uint8_t *) (&tx_data), sizeof(tx_data), 0xfff);
        osDelay(10);
    }
}

static void calculate_task(void *parameter)
{
    for(;;) {
        uint32_t wait_time = xTaskGetTickCount();

        osDelay(10);
    }
}

void controller_init()
{
    DWT_Init(144);
    xTaskCreate(calculate_task, "calculate", 1024, NULL,  10,NULL);
    xTaskCreate(controller_task, "controller", 1024, NULL,  10, NULL);

}